package com.example.pc.adapterdemo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.example.pc.adapterdemo.bean.TabLayoutBean;
import java.util.List;

public class TabLayoutAdapter extends FragmentPagerAdapter {

	private List<TabLayoutBean> mlist;

	public TabLayoutAdapter(FragmentManager fm, List<TabLayoutBean> list) {
		super(fm);
		this.mlist=list;
	}

	public void setDateSource(List<TabLayoutBean> list) {
		this.mlist = list;
	}

	@Override
	public Fragment getItem(int position) {
		return mlist.get(position).getFragment();
	}
	
	@Override
	public CharSequence getPageTitle(int position) {
		return mlist.get(position).getName();
	}

	@Override
	public int getCount() {
		return mlist.size();
	}

}
